jQuery(document).ready(function () {


        /*
            Form validation
        */
        $('.login-form input[type="text"], .login-form input[type="password"], .login-form textarea').on('focus', function () {
            $(this).removeClass('input-error');
        });

        $('.login-form').on('submit', function (e) {

            $(this).find('input[type="text"], input[type="password"], textarea').each(function () {
                if ($(this).val() == "") {
                    e.preventDefault();
                    $(this).addClass('input-error');
                }
                else {
                    $(this).removeClass('input-error');
                }
            });

        });

        $('#form-username').on("blur", function () {
            $.ajax({
                url: "/login/registerName", data: {"username": $("#form-username").val()}, success: function (rs) {
                    $(".news").html(rs)
                }
            })
        });
        $(".form-bottom").on("blur", '#form-password2', function () {
            console.log($("#form-password2").val());
            $.ajax({
                url: "/login/registerPwd",
                data: {"password1": $(".form-password").val(), "password2": $("#form-password2").val()},
                success: function (rs) {
                    $(".newsPwd").html(rs)
                }
            })
        });
        $("#form-email").on("blur",function () {
            $.ajax({
                url: "/login/registerEmail", data: {"email": $("#form-email").val()}, success: function (rs) {
                    $(".newsEmail").html(rs)
                }
            })
        })
    }
);
